{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Drawing Texts\n",
    "\n",
    "This notebook demonstrates basic text rendering APIs."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import skia\n",
    "import contextlib\n",
    "from IPython.display import display, Image\n",
    "\n",
    "@contextlib.contextmanager\n",
    "def draw_target(width=256, height=128):\n",
    "    surface = skia.Surface(width, height)\n",
    "    canvas = surface.getCanvas()\n",
    "    yield canvas\n",
    "    image = surface.makeImageSnapshot()\n",
    "    display(Image(data=image.encodeToData()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In Skia, texts can be drawn onto a canvas via `drawString()` or `drawTextBlob()`. `TextBlob` combines multiple text runs into an immutable container, and allows finer control of glyphs, paint, and positions for each run. The following example shows `drawString()` and `drawTextBlob()` with position specifications."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABHNCSVQICAgIfAhkiAAAD5hJREFUeJztnXe0FsUVwH+jgFhAsSAaQgyCWLFENBZK7MZuLIn9xGiixmhO1CRESVERPYlGTfAYNR4xtqixYcUeIooiSgBFBVHQCGIJL3bh5o/Zp7Ozs7uz+/Zrj/m9s+d9u3tndr797k65c+cuBAKBQCAQCASWOVQVmQhsBuwADIy2QcDHwCxgDjAbuEPBwiquV7KMmwIrR7vvKHilUWXpNAisLXC5gHhuFwt8vUFlnWeU455GlKFTIbBLgR/e3nbLyLePwBnGNqCi8gYFcNClTCKB3sB1jlMvoav9+cCawObABg65WwS2VfCC41x/4Hxjfw6huq4ZpRQAuBKtBO3MBE5R8KAtKNAdOAsYaRzuAYwX2FTBRyXLUJQHgX7R52fqdM3Oh8BXrOp8gcSVIS3dUEdTsI1DbntL5qDafJMAwHIl0mxm7Y/y6d0r+Ccwxjo8uMT1A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EGAByAT0E7kSejbQXgDzV1AvUi120Iw0zNjGsRdSNUIB7Ce+6ptSY9Q0kP2Ba4lb33aNNhfngSMucsfxC64Rtz7Gmo06NwGyEskVu8WjeTccdQdakfPc2tqAA0GNjKriqvGIti62iTimAPWcDBqIfum0qY1twN/rV4YqUa9Hdvj+aKPLYHT7Ogf4N9oncHaNfvh2RgB/y5Gxg3DFOqFVKMDeIK61/6DDug1C3yBX9TjKc0KlSVFL0U/UK8BtDSjAISBnuv0RvuCH1n5ymXwxKnMKHQlS4g2ZjfYIaiQJjyABeSTdICXDLNl7bIlGDAMXAsNAje4E/nHNwAjgEhBjfC8KZC/gMUv2HDtxmSag6HLrOejl1dPQRolHQL2TnSRQkBP0JvPR09SDSfoH3AXqibqXrHpCE2Bsoz2b23EgK7hybOkwp8sg9ohiHHp+xZ6pNBkFHJ3mFtYIQ1CgNOpNkgt6XwQZj7ZODkS/ePsF4BlgJqjMJjsoQKdAfUQyBrMXrdgEmBod4vUEAoFAIBAIBAKBQCAQCAQCgUAgEAgEAoFAIBAIBAKBQCAQCAQCgUAgEAgEAoFAYFnj/z0NY6qGByEDAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "with draw_target(128, 128) as canvas:\n",
    "    paint = skia.Paint(AntiAlias=True, Color=skia.ColorRED)\n",
    "    canvas.drawString('String', 10, 32, skia.Font(None, 36), paint)\n",
    "    \n",
    "    paint.setColor(skia.ColorGREEN)\n",
    "    blob = skia.TextBlob('Blob', skia.Font(None, 36))\n",
    "    canvas.drawTextBlob(blob, 10, 64, paint)\n",
    "    \n",
    "    paint.setColor(skia.ColorBLUE)\n",
    "    blob = skia.TextBlob('Blob', skia.Font(None, 36), [(0, 0), (32, 5), (64, -5), (96, 2)])\n",
    "    canvas.drawTextBlob(blob, 10, 96, paint)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## TextBlob\n",
    "\n",
    "`TextBlob` can be constructed with optional positions or geometric transforms. `RSXform` is a compressed form of rotation+scale matrix."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABHNCSVQICAgIfAhkiAAACVRJREFUeJztnX2MHVUVwH+72yrdClhg11gottZlQ9U0CrVIUwhILPELG6kGAYNiNWqMFlCMGDX1C41CxGCDYmqIBGxMA5sGtxt0jTHBEL+IFrLALoZuiA81JK+J3/j847yxd+7cmTf3vvl4H+eX3GRn9s6cM2/O3Dn33Dv3gKIoiqIoiqIoiqIoiqIoiqIoiqIoiqIog8ZI3Qr0Ia8CVrf//ivwZI26KDVwFGi1ywM169I1o3UroNSLGsCQs6JuBfqQB4Ez23//qk5FiqAoJ/DVwDZgql2mgX8AC8ASsAjcDzxbkDylR3gJcAfHnaJO5ZvAhlo0VQrnEvLfeLu8sQZ9i2ItsLFdJmrWpTYmgQbJG7sAzADfBg60t10G0ATOrlzrYhiobmAoM8Rv6BGkRXBxAvAlkkawCKwqXdPiGXoDOJ34jWwgLUIntpM0gtcFyN8MbG2XPHKLZugN4FLiN/GDHsd+xTr2/QHyzeM/GXB8twyUAYQEgjZb2494HHuvtf2aAPlKgYQEgk6xtjcAv8x57BHgx4bcRoB8pUBCDOB31vZngJ+S72b+B3hTgEwlndci/tB6JEJ5DFgGngF+RgmjlVMknbmjwMeQPnLZqA8gXAL8guS9sMsccF6RgkeAn2QIPALcAlwGvLRIwW3UAOBiOt94u2x1nSjkFdACdgLzSPNjs6ld9rS3l4CfI4Moh4G/BMgM5RxgpbG93C79zBnAfda+xxFjjGIrm4BrrDozSOi+ME4DbsPfEmdI9iR8yNsC7HXIfnMXciPqbgGuJH5N38EdUJtAWmOz7voyFDoNuBq4Gwnx5jWEqwPl5TEAO95Q1M2H+g3gFuLXtSaj7lusum8rW7kxZM7ce4E7if9YrnJ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V2mkajYH5F35tPID/NMQfLqZgPwIJ1v5jEkKmjWOwuJZSh9ziQy3SttwOtzSDzA7vmYTqkyAIwird42pGdxJvEA20bcDrAyRGxB0r1GvsGN9aqjKIqiKIqiKIqiKIqiKIqiKIqiKIqiKIqiKIqiKIqiKIqiKIqiKIqiKEq/8j8s5BNbAlfUvQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "with draw_target(128, 128) as canvas:\n",
    "    paint = skia.Paint(AntiAlias=True)\n",
    "    \n",
    "    blob = skia.TextBlob('Skia', skia.Font(None, 36), [(0, 0), (32, 5), (64, -5), (96, 2)])\n",
    "    canvas.drawTextBlob(blob, 10, 48, paint)\n",
    "    \n",
    "    xform = [\n",
    "        skia.RSXform(1, 0, 0, 0),\n",
    "        skia.RSXform(1.2, 0, 28, 0),\n",
    "        skia.RSXform(0.8, -0.1, 48, 0),\n",
    "        skia.RSXform(1, 0.2, 64, 0),\n",
    "    ]\n",
    "    blob = skia.TextBlob.MakeFromRSXform('Skia', xform, skia.Font(None, 36))\n",
    "    canvas.drawTextBlob(blob, 10, 96, paint)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To build a `TextBlob` with multiple runs, use `TextBlobBuilder`. On drawing, all runs share the same `Paint`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIAAAABACAYAAADS1n9/AAAABHNCSVQICAgIfAhkiAAACKBJREFUeJztnH2sFcUVwH9cH0RURMQ8LaD4BD+wlgZUqE+xiRIjfiFpidZKS7+EthpF/LZVwfgZa2NQiV8xUfGjaSqhtpCmtoklbWNDG5u+qphHC9TKRU0UGk0R+/zjzMmcu3fv3Z17dy/XZn7J5u2dOTt7zu7Z2dl5cw5EIpFIJBKJRCKRSCQSiUQikUgkEolEI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XnI5ND+zmZjchNTGMnPqHSf5ucW2PmPkqp0zIbmZSVV0B7h7TIpVaikfPaqozEz5n0Ie/+QnMIlOEAu4A7kXCu51PqtwF/QoI998eHWf8byZBhORx5J27Gh6JNTMj0IKnnNuMzbvRRj3aTIUkttLdJO+cEakO+85DXVmUl8vT/EUmyuZL6SOmuZD1yw+6h3sl0cKNd8ljqAyJBcgbpu+9Q5EnQ96GdSTzflS/HZ+2q4scYybZ0wFdFBlhJbPm+pr39jMzXyDcG0PkQfZXktRUkJlIHpMPx19Qm60623zX04w3ainzq3It8b+sFOMfIX2dkFyODOk2idJmR0xH/ADKPsBw/mNMcAbcbmW8C38Enm/quaSuPA+D0UYddAPzA2JDlALc6ud/is3/lsfUw/PXTMcsU/AOgr8O09ruGPmSSJhkqvR7p/i0VZNbQyr4C/JDaHqSCTNQkPy+tM/XgHUW3ASSK15LXAQCupTYs/T4nk+UAk/HOpyll8tiqcxJLEu2p82gK/rT2u5JexIOHZ8gNQz6xkjn3klQQB5tI4y+ZCvJePTi3ltm6TSY9E0gWY6lPnJnX1lbbj0Sy+QSbzSF++UsmewAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "with draw_target(128, 64) as canvas:\n",
    "    builder = skia.TextBlobBuilder()\n",
    "    builder.allocRun('First Text', skia.Font(skia.Typeface('Arial'), 24), 0, 0)\n",
    "    builder.allocRun('Second text', skia.Font(skia.Typeface('Arial'), 18), 10, 30)\n",
    "    blob = builder.make()\n",
    "    canvas.drawTextBlob(blob, 10, 32, skia.Paint(AntiAlias=True))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Runs in the blob do not contain text itself, but only glyph indices:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Run([41, 76, 85, 86, 87, 3, 55, 72, 91, 87]),\n",
       " Run([54, 72, 70, 82, 81, 71, 3, 87, 72, 91, 87])]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(blob)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Multiple runs with geometric parameters requires explicit conversion of text to glyphs."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAIAAAABACAYAAADS1n9/AAAABHNCSVQICAgIfAhkiAAACL1JREFUeJztnHnMFEUWwH/fOBBBCCIELxQ/QRFRDLK7Kp4xeOBN1KgIiiKKewSP3fVeV4wajUoIKvGKiYqoIUoQhBiPxPv6VIyoYD6PZdl1UDe7kKy7yu7nH6+Ket1TM90zUzMfYP2SznTXq6muqn796uh6BZFIJBKJRCKRSOTnRVuANPoBk2qIXwQ2AN8Bjwe4fxYF4P81xB8LjK7jPouBr+r4Xy3UWpaWMBzoquFYoX6bzWjgDWBUDf+5ldrKY4/xwXLtp56yZFIMmRiwFvg2I86/At+zEu3Ae3X872vgY0/43urcJ19Xx73yUm9ZWoK2AGfmiL8zcCCwbzMzRTJfId6akknr3gBp1UrosmwktAXIwxpzRDYBCt1wz7OARcCsCvIpRj7VxF2BmNe5wAgTZ2/gAWAl8lasNv/5LaLUVwH3qzTvMfJfhCtGGYOBOcDbJk+dwBPAOE/c00x+FuG3mkcr+TxaX5aaqLUJuIHqncDbjNw+XH2MRQperTP2KvBMBdnxtRZOUa0JOBlR0kp5uoPkiKsforRWvquS7aDS6kRGF6HLEhStAL8Bdqxy9CK/AthjPlLpLyOV+DKucn6FVOYBiIWw//k18lDs9enAPsA2DZSzkgIMVvfpREYDA5G2ep6SpV+Og5XsWVO2gjm34WOAXZpQlqDUMgycTm0KcHVK1oPkQ07LOpG35xZa1wl82ISvA3ZKydpwD7QEbJ2Sz1R5nIS8QPb6EhWvaZ3AEDRTAQZ65J24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RriDZM5+NKFZeBchD3jqI5KCAdKJCTuu2IWbVt89PJBKJRCKRSCQSiUQiWwI/AU8bINMnVJAMAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import random\n",
    "\n",
    "with draw_target(128, 64) as canvas:\n",
    "    builder = skia.TextBlobBuilder()\n",
    "    \n",
    "    font = skia.Font(skia.Typeface('Arial'), 24)\n",
    "    glyphs = font.textToGlyphs('First Text')\n",
    "    xpositions = font.getXPos(glyphs)\n",
    "    xpositions = [x + 5 * random.random() for x in xpositions]\n",
    "    builder.allocRunPosH(font, glyphs, xpositions, 0)\n",
    "    \n",
    "    line_height = font.getSpacing()\n",
    "    \n",
    "    font = skia.Font(skia.Typeface('Arial'), 18)\n",
    "    glyphs = font.textToGlyphs('Second Text')\n",
    "    positions = font.getPos(glyphs, origin=(0, line_height))\n",
    "    positions = [\n",
    "        skia.Point(\n",
    "            p.x() + 3 * random.random(),\n",
    "            p.y() + 5 * random.random())\n",
    "        for i, p in enumerate(positions)]\n",
    "    builder.allocRunPos(font, glyphs, positions)\n",
    "    \n",
    "    blob = builder.make()\n",
    "    paint = skia.Paint(AntiAlias=True)\n",
    "    canvas.drawTextBlob(blob, 10, 24, paint)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Font and Typeface"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`Typeface` specifies the typeface and intrinsic style of a font. `Font` contains `Typeface` and control options applied when drawing and measuring text, such as size information."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Typeface('Arial', FontStyle(700, 5, Slant.kUpright_Slant))\n",
      "Typeface('Arial', FontStyle(400, 5, Slant.kItalic_Slant))\n",
      "Font(Typeface('Times New Roman', FontStyle(400, 5, Slant.kUpright_Slant)), 24.0, 1.0, 0.0)\n"
     ]
    }
   ],
   "source": [
    "bold_typeface = skia.Typeface('Arial', skia.FontStyle.Bold())\n",
    "italic_typeface = skia.Typeface('Arial', skia.FontStyle.Italic())\n",
    "print(bold_typeface)\n",
    "print(italic_typeface)\n",
    "\n",
    "font = skia.Font(skia.Typeface('Times New Roman'), 24)\n",
    "print(font)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Use `Font` to measure various geometry of drawn texts. `measureText` calculates the advance of the text:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "35.98828125"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "font.measureText('text')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Recommended line height is given by `getSpacing`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "27.59765625"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "font.getSpacing()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "For detailed metrics of geometric measurement, obtain `FontMetrics` object."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "FontMetrics(Flags=3, Top=-24.1641, Ascent=-21.3867, Descent=5.19141, Bottom=7.35938, Leading=1.01953, AvgCharWidth=61.6406, MaxCharWidth=61.6406, XMin=-13.6406, XMax=48, XHeight=10.7344, CapHeight=15.8906, UnderlineThickness=1.17188, UnderlinePosition=2.61328, StrikeoutThickness=-5.38825e-33, StrikeoutPosition=4.59163e-41)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "font.getMetrics()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "On drawing, texts are represented by `glyphs`. `Typeface` maintains character to glyph mapping. Unicode texts are mapped one-by-one to glyph indices."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[87, 72, 91, 87]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "glyphs = font.textToGlyphs('text')\n",
    "glyphs"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`glyph` positions and bounding boxes are given by `getPos` and `getBounds`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[Point(10, 10), Point(16.668, 10), Point(27.3203, 10), Point(39.3203, 10)]\n",
      "[Rect(-1, -16, 8, 2), Rect(-1, -13, 11, 2), Rect(-1, -12, 13, 1), Rect(-1, -16, 8, 2)]\n"
     ]
    }
   ],
   "source": [
    "print(font.getPos(glyphs, origin=(10, 10)))\n",
    "print(font.getBounds(glyphs))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Glyphs can be converted to `Path` objects."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<skia.Path at 0x108cb6c70>,\n",
       " <skia.Path at 0x108cb6cb0>,\n",
       " <skia.Path at 0x108cb6cf0>,\n",
       " <skia.Path at 0x108cb6d30>]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "font.getPaths(glyphs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## FontMgr\n",
    "\n",
    "List of available font families can be retrieved by `FontMgr`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Abadi MT Condensed Extra Bold',\n",
       " 'Abadi MT Condensed Light',\n",
       " 'Al Bayan',\n",
       " 'Al Nile',\n",
       " 'Al Tarikh',\n",
       " 'American Typewriter',\n",
       " 'Andale Mono',\n",
       " 'Arial',\n",
       " 'Arial Black',\n",
       " 'Arial Hebrew']"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fontmgr = skia.FontMgr()\n",
    "list(fontmgr)[:10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Each font has specific style presets. For example, `Helvetica` font has 6 styles."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(FontStyle(400, 5, Slant.kUpright_Slant), 'Regular'),\n",
       " (FontStyle(400, 5, Slant.kItalic_Slant), 'Oblique'),\n",
       " (FontStyle(300, 5, Slant.kUpright_Slant), 'Light'),\n",
       " (FontStyle(300, 5, Slant.kItalic_Slant), 'Light Oblique'),\n",
       " (FontStyle(700, 5, Slant.kUpright_Slant), 'Bold'),\n",
       " (FontStyle(700, 5, Slant.kItalic_Slant), 'Bold Oblique')]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "styles = fontmgr.matchFamily('Helvetica')\n",
    "list(styles)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Once a font family and a style is determined, `Typeface` object can be created:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Typeface('Helvetica', FontStyle(700, 5, Slant.kUpright_Slant))"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "styles.createTypeface(4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Alternatively, `FontMgr` can look for closest face."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Typeface('Arial', FontStyle(400, 5, Slant.kUpright_Slant))"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "typeface = fontmgr.matchFamilyStyle('Arial', skia.FontStyle.Normal())\n",
    "typeface"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
